package pers.cz.mxgraph;

import org.dom4j.Attribute;
import org.dom4j.Element;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: Reids
 * @description: 抽象xml element
 * @author: Cheng Zhi
 * @create: 2023-01-06 10:10
 **/
public abstract class MxElement {

    public Element element;

    private Map<String, String> data = new HashMap<String, String>();

    public MxElement(Element element) {
        this.element = element;
    }

    public List<Attribute> getAttributes() {
        return element.attributes();
    }

    public Map<String, String> getData() {
        List<Attribute> attributes = getAttributes();
        for (Attribute attribute : attributes) {
            data.put(attribute.getName(), attribute.getValue());
        }

        return data;
    }

}
